package com.nuonuo.refresh.controller;

import com.nuonuo.middleware.drs.client.annotation.DrsValue;
import com.nuonuo.refresh.service.TestInitializingBeanService;
import com.nuonuo.refresh.service.TestSmartInitializingSingletonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author duan
 * @version 1.0
 * @date 2023/2/2 10:47
 */
@RestController
@RequestMapping(value = "/test")
public class TestController {

    @Value("${nn.id:000}")
    private String id1;

    @DrsValue("${nn.id:000}")
    private String id2;

    @Autowired
    private TestInitializingBeanService testInitializingBeanService;
    @Autowired
    private TestSmartInitializingSingletonService testSmartInitializingSingletonService;

    @GetMapping(value = "sayHello")
    public String sayHello() {
        testInitializingBeanService.sayHello();
        testSmartInitializingSingletonService.sayHello();
        return "OK";
    }


    @GetMapping("printId")
    public String printId() {
        return "value id:" + id1 + "\ndrsValue id:" + id2;
    }
}
